home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / cc_base / pak00_16bit_f.pk3 / scenario_wizard.gl.p < prev    next >
Text File  |  2003-09-23  |  18KB  |  513 lines

  1. {
  2.   
  3.      
  4.   ChildID = {
  5.    
  6.     GuiAnimation("Plate") {
  7.       AnimationID = "image/scenario_wizard.pcx";
  8.       X = 0;
  9.       Y = 0;
  10.       Width = 640;
  11.       Height = 480;
  12.     },          
  13.  
  14.     GuiListbox("start_city") {
  15.       X      = 36;
  16.       Y      = 59;
  17.       Height = 97;
  18.       Width  = 194;
  19.       FontID = "font/verdana_black_bold_14.tf";
  20.       ListFontID = "font/verdana_black_bold_12.tf";
  21.       ListHilightedColor = #7FAFFF;
  22.       TextID = Mangle(194/*"Starting City:"*/);
  23.       HorizontalAlign = LEFT;
  24.       VerticalAlign = ABOVE;
  25.         
  26.       ScriptID = Script {
  27.         @loaded {
  28.           GuiListBoxLoadCSVColumn(SELF,ResPropGetResID(ResByName("CSVData"), "city_id"),"name");
  29.         }
  30.       };
  31.       
  32.       StrListID = StrList {
  33.         Size = 10240;
  34.       };
  35.   
  36.       ChildID = {
  37.         GuiScrollBar ("sb") {
  38.           Kind = VERTICAL;
  39.           ChildID = {
  40.             GuiButton("thumb") {
  41.               StyleID = "gui/square/scrollbar/sb_thumb.gbs";
  42.             },
  43.             GuiButton("dec") {
  44.               StyleID = "gui/square/scrollbar/sb_uarrow.gbs";
  45.             },
  46.             GuiButton("inc") {
  47.               StyleID = "gui/square/scrollbar/sb_darrow.gbs";
  48.             }
  49.           };
  50.         }
  51.       };
  52.     },
  53.     
  54.     GuiListbox("end_city") {
  55.       X      = 269;
  56.       Y      = 59;
  57.       Height = 97;
  58.       Width  = 195;
  59.       FontID = "font/verdana_black_bold_14.tf";
  60.       ListFontID = "font/verdana_black_bold_12.tf";
  61.       ListHilightedColor = #7FAFFF;
  62.       TextID = Mangle(195/*"Ending City:"*/);
  63.       HorizontalAlign = LEFT;
  64.       VerticalAlign = ABOVE;
  65.       
  66.       ScriptID = Script {
  67.         @loaded {
  68.           GuiListBoxLoadCSVColumn(SELF,ResPropGetResID(ResByName("CSVData"), "city_id"),"name");
  69.         }
  70.       };
  71.       StrListID = StrList {
  72.         Size = 10240;
  73.       };
  74.  
  75.       ChildID = {
  76.         GuiScrollBar ("sb") {
  77.           Kind = VERTICAL;
  78.           ChildID = {
  79.             GuiButton("thumb") {
  80.               StyleID = "gui/square/scrollbar/sb_thumb.gbs";
  81.             },
  82.             GuiButton("dec") {
  83.               StyleID = "gui/square/scrollbar/sb_uarrow.gbs";
  84.             },
  85.             GuiButton("inc") {
  86.               StyleID = "gui/square/scrollbar/sb_darrow.gbs";
  87.             }
  88.           };
  89.         }
  90.       };
  91.     },
  92.     
  93.     GuiListbox("avail_commodity") {
  94.       X      = 36;
  95.       Y      = 186;
  96.       Height = 202;
  97.       Width  = 196;
  98.       FontID = "font/verdana_black_bold_14.tf";
  99.       ListFontID = "font/verdana_black_bold_12.tf";
  100.       ListHilightedColor = #7FAFFF;
  101.  
  102.       TextID = Mangle(196/*"Available Commodities:"*/);
  103.       HorizontalAlign = LEFT;
  104.       VerticalAlign = ABOVE;
  105.       
  106.       ScriptID = Script {
  107.         @loaded {
  108.           GuiListBoxLoadCSVColumn(SELF,ResPropGetResID(ResByName("CSVData"), "commodity_id"),"name");
  109.         }
  110.       };
  111.       StrListID = StrList {
  112.         Size = 10240;
  113.       };
  114.  
  115.       ChildID = {
  116.         GuiScrollBar ("sb") {
  117.           Kind = VERTICAL;
  118.           ChildID = {
  119.             GuiButton("thumb") {
  120.               StyleID = "gui/square/scrollbar/sb_thumb.gbs";
  121.             },
  122.             GuiButton("dec") {
  123.               StyleID = "gui/square/scrollbar/sb_uarrow.gbs";
  124.             },
  125.             GuiButton("inc") {
  126.               StyleID = "gui/square/scrollbar/sb_darrow.gbs";
  127.             }
  128.           };
  129.         }
  130.       };
  131.     },
  132.  
  133.     GuiListbox("picked_commodity") {
  134.       X      = 380;
  135.       Y      = 187;
  136.       Height = 98;
  137.       Width  = 200;
  138.       FontID = "font/verdana_black_bold_14.tf";      
  139.       ListFontID = "font/verdana_black_bold_12.tf";
  140.       ListHilightedColor = #7FAFFF;
  141.       
  142.       TextID = Mangle(197/*"Selected Commodities:"*/);
  143.       HorizontalAlign = LEFT;
  144.       VerticalAlign = ABOVE;
  145.  
  146.       ScriptID = Script {
  147.         @loaded {
  148.         }
  149.       };
  150.       StrListID = StrList {
  151.         Size = 10240;
  152.         Duplicate = FALSE;
  153.         Indexed = TRUE;
  154.       };
  155.  
  156.       ChildID = {
  157.         GuiScrollBar ("sb") {
  158.           Kind = VERTICAL;
  159.           ScriptID = script {
  160.             @update {            
  161.               ResPropSetInt(SELF, "Value", ResPropGetInt(SELF, "MaxValue"));
  162.             }
  163.           }
  164.           ChildID = {
  165.             GuiButton("thumb") {
  166.               StyleID = "gui/square/scrollbar/sb_thumb.gbs";
  167.             },
  168.             GuiButton("dec") {
  169.               StyleID = "gui/square/scrollbar/sb_uarrow.gbs";
  170.             },
  171.             GuiButton("inc") {
  172.               StyleID = "gui/square/scrollbar/sb_darrow.gbs";
  173.             }
  174.           };
  175.         }
  176.       };
  177.     },
  178.  
  179.         GuiTextInput("bonus") {
  180.       X = 382;
  181.       Y = 310;        
  182.       Width = 190;
  183.       Height = 40;
  184.       WordWrap = FALSE;
  185.       InputDisabled = TRUE;
  186.       TextID = Mangle(198/*"Bonus Commodity:"*/);
  187.       HorizontalAlign = LEFT;
  188.       VerticalAlign = ABOVE;
  189.       FontID = "font/verdana_black_bold_12.tf";      
  190.     },
  191.     
  192.     GuiTextInput("scenario_creator") {
  193.       X = 0;
  194.       Y = 30;
  195.       Width = 640;
  196.       Height = 40;
  197.       WordWrap = FALSE;
  198.       InputDisabled = TRUE;   
  199.       TextID = Mangle(199/*"Scenario Creator"*/);
  200.       HorizontalAlign = CENTER;
  201.       VerticalAlign = ABOVE;
  202.       FontID = "font/verdana_black_bold_18.tf";      
  203.     },
  204.  
  205.         GuiTextInput("filename") {
  206.       X = 382;
  207.       Y = 363;
  208.       Width = 190;
  209.       Height = 40;
  210.       WordWrap = FALSE;
  211.       InsertCursorID = "gui/dash/tab/insert_cursor.pcx";
  212.       OverwriteCursorID = "gui/dash/tab/overwrite_cursor.pcx";      
  213.       TextID = Mangle(200/*"File name:"*/);
  214.       HorizontalAlign = LEFT;
  215.       VerticalAlign = ABOVE;
  216.       FontID = "font/verdana_black_bold_12.tf";      
  217.     },
  218.  
  219.  
  220.     GuiButton("add_arrow") {
  221.       X = 260;
  222.       Y = 200;
  223.       TextID = Mangle(201/*"Add ->"*/);
  224.       StyleID = "gui/dash/tab/button/tab.gbs";
  225.       FontID = "font/tab_button.tf";
  226.       Width = 80;
  227.       AutoSize = HEIGHT;
  228.       ScriptID = Script {
  229.         @activate {
  230.           str tmp;
  231.           int i;
  232.           resid Messages_id;
  233.           resid picked_id;
  234.           
  235.           picked_id = GuiSiblingByName("picked_commodity");
  236.           
  237.           Messages_id = GuiSiblingByName("messages");
  238.          
  239.           /* clear message textbox */
  240.           ResPropSetStr(Messages_id,"InputText", "");
  241.          
  242.           if (ResPropGetInt(picked_id, "Count") >= 12) {
  243.             ResPropSetStr(Messages_id,"InputText",MangleSIDToStr(202/*"You may only add up to 12 commodities."*/));
  244.             stop;
  245.           }
  246.          
  247.           /* get selected commodity */
  248.           tmp = GuiListboxGetSelected(GuiSiblingByName("avail_commodity"));
  249.          
  250.          
  251.           GuiListBoxAppend(GuiSiblingByName("picked_commodity"),tmp);
  252.           ResParseEvent(GuiSiblingByName("picked_commodity/sb"), "@update");
  253.          
  254.         }
  255.       };
  256.     },
  257.       
  258.     GuiButton("Clear") {
  259.       X = 260;
  260.       Y = 358;
  261.       TextID = Mangle(204/*"Clear"*/);
  262.       StyleID = "gui/dash/tab/button/tab.gbs";
  263.       FontID = "font/tab_button.tf";
  264.       Width = 80;
  265.       AutoSize = HEIGHT;
  266.       ScriptID = Script {
  267.         @activate {
  268.          GuiListboxClear(GuiSiblingByName("picked_commodity"));
  269.          ResPropSetStr(GuiSiblingByName("bonus"),"InputText","");
  270.          
  271.          /* clear message textbox */
  272.          ResPropSetStr(GuiSiblingByName("messages"),"InputText", "");
  273.         }
  274.       };
  275.     },
  276.     GuiButton("add_bonus_arrow") {
  277.       X = 260;
  278.       Y = 305;
  279.       TextID = Mangle(205/*"Bonus ->"*/);
  280.       StyleID = "gui/dash/tab/button/tab.gbs";
  281.       FontID = "font/tab_button.tf";
  282.       AutoSize = HEIGHT;
  283.       Width = 80;      
  284.       ScriptID = Script {
  285.         @activate {
  286.          str tmp;
  287.          
  288.          /* clear message textbox */
  289.          ResPropSetStr(GuiSiblingByName("messages"),"InputText", "");
  290.          
  291.          tmp = GuiListboxGetSelected(GuiSiblingByName("avail_commodity"));
  292.          ResPropSetStr(GuiSiblingByName("bonus"),"InputText",tmp);
  293.         }
  294.       };
  295.     },
  296.  
  297.  
  298.  
  299.         GuiTextInput("messages") {
  300.       X = 30;
  301.       Y = 400;
  302.       Width = 255;
  303.       Height = 60;
  304.       WordWrap = TRUE;
  305.       FontID = "font/verdana_black_bold_12.tf";
  306.     },
  307.  
  308.     GuiButton("save") {
  309.       X = 515;
  310.       Y = 430;
  311.       TextID = Mangle(206/*"Save"*/);
  312.       StyleID = "gui/dash/tab/button/tab.gbs";
  313.       FontID = "font/tab_button.tf";
  314.       Width = 100;
  315.       AutoSize = HEIGHT;
  316.       ScriptID = Script {
  317.         @activate {
  318.           resid Player1Scenario;
  319.           resid Player2Scenario;
  320.           resid ScenarioGroup;
  321.           resid csv_data_id;
  322.           resid city_data_id;
  323.           resid state_data_id;
  324.  
  325.           resid com_picked_id;
  326.           resid messages_id;  
  327.           
  328.           str com1;
  329.           str com2;
  330.           str com3;
  331.           str com4;
  332.           str com5;
  333.           str com6;
  334.           str com7;
  335.           str com8;
  336.           str com9;
  337.           str com10;
  338.           str com11;
  339.           str com12;
  340.           str start_city;
  341.           str end_city;
  342.           str start_state_name;
  343.           str end_state_name;
  344.           str bonus;
  345.           str filename;
  346.           str full_path;
  347.           
  348.           int i;
  349.         
  350.           /* get player view city information */
  351.           csv_data_id = ResByName("CSVData");
  352.           city_data_id = ResPropGetResID(csv_data_id, "city_id");
  353.           state_data_id = ResPropGetResID(csv_data_id, "state_id");
  354.  
  355.           Player1Scenario = ResByName("Player1Scenario");
  356.           Player2Scenario = ResByName("Player2Scenario");
  357.           ScenarioGroup   = ResByName("ScenarioGroup");
  358.           messages_id     = GuiSiblingByName("messages");
  359.  
  360.           com_picked_id = GuiSiblingByName("picked_commodity");
  361.  
  362.           com1  = GuiListboxAt(com_picked_id, 0);
  363.           com2  = GuiListboxAt(com_picked_id, 1);
  364.           com3  = GuiListboxAt(com_picked_id, 2);
  365.           com4  = GuiListboxAt(com_picked_id, 3);
  366.           com5  = GuiListboxAt(com_picked_id, 4);
  367.           com6  = GuiListboxAt(com_picked_id, 5);
  368.           com7  = GuiListboxAt(com_picked_id, 6);
  369.           com8  = GuiListboxAt(com_picked_id, 7);
  370.           com9  = GuiListboxAt(com_picked_id, 8);
  371.           com10 = GuiListboxAt(com_picked_id, 9);
  372.           com11 = GuiListboxAt(com_picked_id, 10);
  373.           com12 = GuiListboxAt(com_picked_id, 11);
  374.  
  375.           start_city = GuiListboxGetSelected(GuiSiblingByName("start_city"));
  376.           end_city   = GuiListboxGetSelected(GuiSiblingByName("end_city"));
  377.           bonus      = ResPropGetStr(GuiSiblingByName("bonus"),"InputText");
  378.           
  379.           if ( StrExact(com1,"") ) {
  380.             ResPropSetStr(messages_id,"InputText",MangleSIDToStr(207/*"You must select at least one commodity."*/));         
  381.             stop;
  382.           }          
  383.           if ( StrExact(start_city,"") ) {
  384.             ResPropSetStr(messages_id,"InputText",MangleSIDToStr(208/*"You must select a starting city."*/));
  385.             stop;
  386.           }
  387.           if ( StrExact(end_city,"") ) {
  388.             ResPropSetStr(messages_id,"InputText",MangleSIDToStr(209/*"You must select an ending city."*/));
  389.             stop;
  390.           }
  391.        
  392.           /* SET ALL THE VALUES INTO SCENARIO OBJECTS  */
  393.           ResPropSetInt(Player1Scenario,"scenario_commodity_number_of",
  394.             ResPropGetInt(com_picked_id, "Count"));
  395.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_1",com1);
  396.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_2",com2);
  397.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_3",com3);
  398.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_4",com4);
  399.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_5",com5);
  400.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_6",com6);
  401.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_7",com7);
  402.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_8",com8);
  403.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_9",com9);
  404.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_10",com10);
  405.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_11",com11);
  406.           ResPropSetStr(Player1Scenario,"scenario_commodity_name_12",com12);                    
  407.           ResPropSetStr(Player1Scenario,"scenario_commodity_bonus",bonus);       
  408.           ResPropSetStr(Player1Scenario,"scenario_start_city",start_city);
  409.           ResPropSetStr(Player1Scenario,"scenario_end_city",end_city);
  410.           /* get the start state */          
  411.           start_state_name = CSVGetStr(state_data_id,"name", CSVSearch(state_data_id,"abbreviation", CSVGetStr(city_data_id,"state", CSVSearch(city_data_id,"name",start_city))));         
  412.           end_state_name   = CSVGetStr(state_data_id,"name", CSVSearch(state_data_id,"abbreviation", CSVGetStr(city_data_id,"state", CSVSearch(city_data_id,"name",end_city))));   
  413.           ResPropSetStr(Player1Scenario,"scenario_start_state", start_state_name);
  414.           ResPropSetStr(Player1Scenario,"scenario_end_state", end_state_name);
  415.           
  416.           ResPropSetInt(Player2Scenario,"scenario_commodity_number_of",
  417.             ResPropGetInt(com_picked_id, "Count"));
  418.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_1",com1);
  419.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_2",com2);
  420.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_3",com3);
  421.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_4",com4);
  422.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_5",com5);
  423.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_6",com6);
  424.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_7",com7);
  425.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_8",com8);
  426.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_9",com9);
  427.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_10",com10);
  428.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_11",com11);
  429.           ResPropSetStr(Player2Scenario,"scenario_commodity_name_12",com12);                    
  430.           ResPropSetStr(Player2Scenario,"scenario_commodity_bonus",bonus);       
  431.           ResPropSetStr(Player2Scenario,"scenario_start_city",start_city);
  432.           ResPropSetStr(Player2Scenario,"scenario_end_city",end_city);
  433.           ResPropSetStr(Player2Scenario,"scenario_start_state", start_state_name);
  434.           ResPropSetStr(Player2Scenario,"scenario_end_state", end_state_name);
  435.           
  436.           /* check if bonus commodity and regular are duplicate */
  437.           i = 0;
  438.           while (i<ResPropGetInt(com_picked_id, "Count")) {
  439.             if (StrExact(bonus, GuiListboxAt(com_picked_id,i))) {
  440.               ResPropSetStr(messages_id,"InputText",MangleSIDToStr(210/*"You cannot have a duplicate bonus commodity and selected commodity."*/));
  441.               stop; 
  442.             }
  443.             i+=1;
  444.           }
  445.           
  446.           /* check if start city and end city r the same */
  447.           if ( StrExact(start_city, end_city)) {
  448.             ResPropSetStr(messages_id,"InputText",MangleSIDToStr(211/*"Starting City and Ending City cannot be the same."*/));
  449.             stop;            
  450.           }
  451.    
  452.           if ( CSVGetInt(city_data_id,"can_start_in",CSVSearch(city_data_id,"name",start_city)) == 0 ) {
  453.             ResPropSetStr(messages_id,"InputText", StrFormatStr(MangleSIDToStr(212/*"You cannot start in %s."*/),start_city));
  454.             stop;      
  455.           }
  456.  
  457.           if ( CSVGetInt(city_data_id,"can_start_in",CSVSearch(city_data_id,"name",end_city)) == 0 ) {
  458.             ResPropSetStr(messages_id,"InputText", StrFormatStr(MangleSIDToStr(213/*"You cannot end in %s."*/), end_city));
  459.             stop;      
  460.           }
  461.  
  462.           /* get the filename */          
  463.           filename = ResPropGetStr(GuiSiblingByName("filename"),"InputText");
  464.           
  465.           /* check if the filename is empty */
  466.           if (StrExact("",filename)) {
  467.             ResPropSetStr(messages_id,"InputText",MangleSIDToStr(214/*"You must type a file name."*/));              
  468.             stop;
  469.           }
  470.           
  471.           /* check that the length of the filename is not too long */
  472.           if (StrLen(filename) >= 27) {
  473.             ResPropSetStr(messages_id,"InputText",MangleSIDToStr(215/*"The file name you have chosen is too long."*/));
  474.             stop;
  475.           }          
  476.                  
  477.           /* form the full path */
  478.           if (StrIn(filename, ".scn")) {
  479.             full_path = StrFormatStr("%s%s", CVarGetStr("SavedScenarioDir"),filename);
  480.           } else {
  481.             filename = StrFormatStr("%s.scn", filename);
  482.             full_path = StrFormatStr("%s%s", CVarGetStr("SavedScenarioDir"),filename);
  483.           }
  484.            
  485.           /* save the game */
  486.           if (ResSaveAs(ScenarioGroup, full_path)) {
  487.             ResPropSetStr(messages_id,"InputText",StrFormatStr(MangleSIDToStr(216/*"Your scenario has been saved to '%s'."*/), filename));            
  488.           } else {
  489.             ResPropSetStr(messages_id,"InputText",MangleSIDToStr(217/*"Could not save scenario. Check save scenario path in options menu."*/));
  490.           }    
  491.         }
  492.       };
  493.     },
  494.  
  495.     GuiButton("main_menu") {
  496.       X = 384;
  497.       Y = 430;
  498.       TextID = Mangle(218/*"Main Menu"*/);
  499.       StyleID = "gui/dash/tab/button/tab.gbs";
  500.       FontID = "font/tab_button.tf";
  501.       Width = 100;
  502.       AutoSize = HEIGHT;
  503.       ScriptID = Script {
  504.         @activate {
  505.           release("floor");
  506.           mark("floor");
  507.           ResByName("splash_screen.gl");
  508.         }
  509.       };
  510.     }
  511.   };
  512. }
  513.